/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package millionaire;

/**
 *
 * @author huseyngasimov
 */
public class AddQuestion extends javax.swing.JFrame {

    /**
     * Creates new form AddQuestion
     */
    
    private Main mainForm;
    
    public AddQuestion(Main mainForm) {
        initComponents();
        this.mainForm = mainForm;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grpCorrectAnswer = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtQuestion = new javax.swing.JTextArea();
        txtAnswerA = new javax.swing.JTextField();
        txtAnswerB = new javax.swing.JTextField();
        txtAnswerC = new javax.swing.JTextField();
        txtAnswerD = new javax.swing.JTextField();
        lblQuestion = new javax.swing.JLabel();
        rdAnswerB = new javax.swing.JRadioButton();
        rdAnswerA = new javax.swing.JRadioButton();
        rdAnswerC = new javax.swing.JRadioButton();
        rdAnswerD = new javax.swing.JRadioButton();
        lblAnswers = new javax.swing.JLabel();
        btnAdd = new javax.swing.JButton();
        btnClear = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        txtQuestion.setColumns(20);
        txtQuestion.setRows(5);
        txtQuestion.setText("Your Question ...");
        txtQuestion.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtQuestion_FocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtQuestion_FocusLost(evt);
            }
        });
        jScrollPane1.setViewportView(txtQuestion);

        txtAnswerA.setText("Answer A ...");
        txtAnswerA.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtAnswerA_FocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtAnswerA_FocusLost(evt);
            }
        });

        txtAnswerB.setText("Answer B ...");
        txtAnswerB.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtAnswerB_FocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtAnswerB_FocusLost(evt);
            }
        });

        txtAnswerC.setText("Answer C ...");
        txtAnswerC.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtAnswerC_FocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtAnswerC_FocusLost(evt);
            }
        });

        txtAnswerD.setText("Answer D ...");
        txtAnswerD.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtAnswerD_FocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtAnswerD_FocusLost(evt);
            }
        });

        lblQuestion.setText("Your Question:");

        grpCorrectAnswer.add(rdAnswerB);

        grpCorrectAnswer.add(rdAnswerA);

        grpCorrectAnswer.add(rdAnswerC);

        grpCorrectAnswer.add(rdAnswerD);

        lblAnswers.setText("Answers and Correct Answer:");

        btnAdd.setText("Add");

        btnClear.setText("Clear");
        btnClear.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnClear_Click(evt);
            }
        });

        btnCancel.setText("Cancel");
        btnCancel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnCancel_Click(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jScrollPane1)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                                        .add(rdAnswerA)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(txtAnswerA))
                                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(lblQuestion)
                                        .add(layout.createSequentialGroup()
                                            .add(rdAnswerC)
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                            .add(txtAnswerC, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 255, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                                        .add(btnAdd)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                        .add(btnClear)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(btnCancel))
                                    .add(layout.createSequentialGroup()
                                        .add(rdAnswerB)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(txtAnswerB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 255, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                                        .add(rdAnswerD)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .add(txtAnswerD, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 255, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))))
                    .add(layout.createSequentialGroup()
                        .add(15, 15, 15)
                        .add(lblAnswers)
                        .add(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(11, 11, 11)
                .add(lblQuestion)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(36, 36, 36)
                .add(lblAnswers)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(rdAnswerA)
                    .add(rdAnswerB)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(txtAnswerA, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(txtAnswerB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(rdAnswerC)
                    .add(txtAnswerD, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(txtAnswerC, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(rdAnswerD))
                .add(63, 63, 63)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnAdd)
                    .add(btnClear)
                    .add(btnCancel))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txtQuestion_FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtQuestion_FocusGained
        if("Your Question ...".equals(txtQuestion.getText())){
            txtQuestion.setText("");
        }
    }//GEN-LAST:event_txtQuestion_FocusGained

    private void txtQuestion_FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtQuestion_FocusLost
        if("".equals(txtQuestion.getText())){
            txtQuestion.setText("Your Question ...");
        }
    }//GEN-LAST:event_txtQuestion_FocusLost

    private void txtAnswerA_FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtAnswerA_FocusGained
        if("Answer A ...".equals(txtAnswerA.getText())){
            txtAnswerA.setText("");
        }
    }//GEN-LAST:event_txtAnswerA_FocusGained

    private void txtAnswerA_FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtAnswerA_FocusLost
        if("".equals(txtAnswerA.getText())){
            txtAnswerA.setText("Answer A ...");
        }
    }//GEN-LAST:event_txtAnswerA_FocusLost

    private void txtAnswerB_FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtAnswerB_FocusGained
        if("Answer B ...".equals(txtAnswerB.getText())){
            txtAnswerB.setText("");
        }
    }//GEN-LAST:event_txtAnswerB_FocusGained

    private void txtAnswerB_FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtAnswerB_FocusLost
        if("".equals(txtAnswerB.getText())){
            txtAnswerB.setText("Answer B ...");
        }
    }//GEN-LAST:event_txtAnswerB_FocusLost

    private void txtAnswerC_FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtAnswerC_FocusGained
        if("Answer C ...".equals(txtAnswerC.getText())){
            txtAnswerC.setText("");
        }
    }//GEN-LAST:event_txtAnswerC_FocusGained

    private void txtAnswerC_FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtAnswerC_FocusLost
        if("".equals(txtAnswerC.getText())){
            txtAnswerC.setText("Answer C ...");
        }
    }//GEN-LAST:event_txtAnswerC_FocusLost

    private void txtAnswerD_FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtAnswerD_FocusGained
        if("Answer D ...".equals(txtAnswerD.getText())){
            txtAnswerD.setText("");
        }
    }//GEN-LAST:event_txtAnswerD_FocusGained

    private void txtAnswerD_FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtAnswerD_FocusLost
        if("".equals(txtAnswerD.getText())){
            txtAnswerD.setText("Answer D ...");
        }
    }//GEN-LAST:event_txtAnswerD_FocusLost

    private void btnCancel_Click(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancel_Click
        Clear();
        this.setVisible(false);
        mainForm.setVisible(true);
    }//GEN-LAST:event_btnCancel_Click

    private void btnClear_Click(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnClear_Click
        Clear();
    }//GEN-LAST:event_btnClear_Click

    private void Clear() {
        txtQuestion.setText("Your Question ...");
        txtAnswerA.setText("Answer A ...");
        txtAnswerB.setText("Answer B ...");
        txtAnswerC.setText("Answer C ...");
        txtAnswerD.setText("Answer D ...");
        
        grpCorrectAnswer.clearSelection();
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdd;
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnClear;
    private javax.swing.ButtonGroup grpCorrectAnswer;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblAnswers;
    private javax.swing.JLabel lblQuestion;
    private javax.swing.JRadioButton rdAnswerA;
    private javax.swing.JRadioButton rdAnswerB;
    private javax.swing.JRadioButton rdAnswerC;
    private javax.swing.JRadioButton rdAnswerD;
    private javax.swing.JTextField txtAnswerA;
    private javax.swing.JTextField txtAnswerB;
    private javax.swing.JTextField txtAnswerC;
    private javax.swing.JTextField txtAnswerD;
    private javax.swing.JTextArea txtQuestion;
    // End of variables declaration//GEN-END:variables
}
